﻿@model BetterTaskList.Models.Ticket
 
 @if(new BetterTaskList.Models.Tickets.TicketCommentRepository().GetTicketCommentCount(Model.TicketId) > 0)
 {
     <div id="comments">
        <h3>Comments</h3>
        <ol class="comment-list">

        @foreach (var comment in new BetterTaskList.Models.Tickets.TicketCommentRepository().GetTicketComments(Model.TicketId))
        {
            <li id="comment-@comment.TicketCommentId" class="comment alt thread-even depth-1" >
               
            @Html.Partial("_DisplayCommentParent", comment)
            
            <ul class="children">   
                @foreach (var reply in new BetterTaskList.Models.Tickets.TicketCommentRepository().GetTicketCommentReplys(comment.TicketCommentId))
                {
                  @Html.Partial("_DisplayCommentChild", reply)  
                }
            </ul>

            <div class="reply">
			    <a id="toggleReply-@comment.TicketCommentId" href="#">Reply</a>
                    
                    <div id="commentReply-@comment.TicketCommentId" style="display:none; margin-left:18px;">
                    @using (Html.BeginForm("PostCommentReply", "Ticket", new { area = "Projects", id = Model.TicketId, ticketCommentId = comment.TicketCommentId }, FormMethod.Post))
                     {		
                          @Html.TextArea("CommentReplyDetails", null, new { @style = "width:548px; color:#999999; border: 1px solid #CCCCCC; height:26px;", @Class = "CommentReplyTextBox" })
                          <div style="text-align:right; padding-top:2px; ">
                              <input id="submitReply-@comment.TicketCommentId" type="submit" value="Post Reply" />
                          </div>
                     } 
                    </div>

                <script type="text/javascript">
                    $(function () {

                        $("#submitReply-@comment.TicketCommentId").button();

                        $("#toggleReply-@comment.TicketCommentId").click(function () {
                            $("#commentReply-@comment.TicketCommentId").toggle("Slide", null, 500);
                            return false; });

                    });
                </script>

           </div>
           </li>
            
        } 
       </ol>
</div> 
 }
